import requests
from bs4 import BeautifulSoup

base_url = "https://hz.lianjia.com"
list_url = "/zufang/#contentList"


def get_page(url):
    response = requests.get(url)
    # print(response.text)
    soup = BeautifulSoup(response.text, "html.parser")
    # print(soup)
    return soup


def get_links(url):
    soup = get_page(url)
    links_a = soup.find_all("a", class_="content__list--item--aside")
    # print(links_a)
    links = [base_url + a.get("href") for a in links_a]
    # print(links)
    return links


house_url = get_links(base_url + list_url)[0]
soup = get_page(house_url)
house_title = soup.find("div", class_="content__aside--title")
print(house_title)
print("----------------")
print(house_title.text)
print("----------------")
print(house_title.string)
print("----------------")
print(house_title.next_element)
print("----------------")
print(house_title.next_sibling)

